import {
  q as r,
  p as J,
  ap as L,
  X as p,
  f as U,
  H as V,
  av as m,
  aw as z,
  k as t,
  l,
  m as s,
  az as M,
  at as f,
  as as c
} from "./index-30f27935.js";
import { j as N, a as T } from "./vip-8a4bc37f.js";
function _(h) {
  const d = r([]),
    u = r(!0);
  r({}), J();
  const y = L("reload"),
    g = p({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    x = p({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    v = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 100 },
      {
        label: "用户",
        prop: "user_name",
        minWidth: 130,
        formatter: ({ user_name: e, user_phone: a }) =>
          t("div", null, [t("div", null, [e]), t("div", null, [a])])
      },
      {
        label: "身份",
        prop: "user_vip",
        minWidth: 200,
        formatter: ({ user_vip: e, user_place: a, user_group: n }) =>
          t("div", null, [
            " ",
            t("span", null, [
              e == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("VIP会员")] }
                  )
                : t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("普通会员")] }
                  )
            ]),
            t("span", null, [
              a == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("一星合伙人")] }
                  )
                : a == 2
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("二星合伙人")] }
                  )
                : a == 3
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("三星合伙人")] }
                  )
                : a == 4
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("四星合伙人")] }
                  )
                : a == 5
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("五星合伙人")] }
                  )
                : a == 6
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("一星联创")] }
                  )
                : a == 7
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("二星联创")] }
                  )
                : a == 8
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("三星联创")] }
                  )
                : a == 9
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("四星联创")] }
                  )
                : a == 10
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("一星董事")] }
                  )
                : a == 11
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("二星董事")] }
                  )
                : a == 12
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("三星董事")] }
                  )
                : t(
                    l("el-tag"),
                    { class: "mx-1", type: "info", effect: "light" },
                    { default: () => [s("暂无")] }
                  )
            ]),
            t("span", null, [
              n == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("团长")] }
                  )
                : t(
                    l("el-tag"),
                    { class: "mx-1", type: "info", effect: "light" },
                    { default: () => [s("暂无")] }
                  )
            ])
          ])
      },
      { label: "积分", prop: "user_money", minWidth: 100 },
      { label: "收益", prop: "user_income", minWidth: 100 },
      { label: "云值", prop: "user_value", minWidth: 100 },
      {
        label: "推荐关系",
        prop: "suggest_name",
        minWidth: 220,
        formatter: ({ suggest_name: e, suggest_phone: a }) =>
          t("div", null, [e ? t("div", null, [s("推荐人 "), e + ":" + a]) : ""])
      },
      { label: "注册时间", minWidth: 180, prop: "create_time" },
      { label: "操作", fixed: "right", width: 230, slot: "operation" }
    ],
    E = U(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function B(e) {
    M(e);
  }
  async function F(e) {
    if (
      (e.user_money != 0 && e.user_money) ||
      (e.user_income != 0 && e.user_income)
    ) {
      f("账户积分或收益没有清空，无法注销", { type: "error" });
      return;
    }
    const a = { user_id: e.user_id, action: "userOff" },
      n = JSON.stringify(a),
      o = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(n)) },
      i = await N(o);
    i.code == 200
      ? (f("注销成功", { type: "success" }), y())
      : f(i.msg, { type: "error" });
  }
  function b() {}
  function A(e) {}
  function C(e) {}
  function S(e) {}
  function W(e) {
    (x.text = `正在加载第${e}页...`),
      (u.value = !0),
      m(600).then(() => {
        u.value = !1;
      });
  }
  async function I(e) {
    u.value = !0;
    const n = JSON.stringify({ name_phone: e }),
      o = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(n)) },
      { data: i } = await T(o);
    (d.value = i.data),
      (g.total = i.total),
      setTimeout(() => {
        u.value = !1;
      }, 500);
  }
  async function k() {
    setTimeout(() => {
      u.value = !1;
    }, 500);
  }
  const w = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    V(() => {
      m().then(() => {
        const { setWatermark: e } = z(h.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        k();
    }),
    {
      loading: u,
      columns: v,
      dataList: d,
      pagination: g,
      buttonClass: E,
      onSearch: I,
      resetForm: w,
      handleaddUser: b,
      handleUpdate: B,
      handleDelete: F,
      handleSizeChange: A,
      handleCurrentChange: C,
      handleSelectionChange: S,
      onCurrentChange: W
    }
  );
}
export { _ as useRole };
